﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ConsumeSys.BLL;
using ConsumeSys.Common;
using ConsumeSys.Model;

namespace ConsumeSys.Controllers
{
    /// <summary>
    /// Controller基类
    /// </summary>
    public abstract class BaseController : Controller
    {
        /// <summary>
        /// 是否是Get请求
        /// </summary>
        public bool IsGet
        {
            get { return Request.HttpMethod.ToUpper().Equals("GET"); }
        }
        /// <summary>
        /// 是否是Post请求
        /// </summary>
        public bool IsPost
        {
            get { return Request.HttpMethod.ToUpper().Equals("POST"); }
        }

        /// <summary>
        /// 获取当前登录用户
        /// </summary>
        /// 2019-11-14 00:43:21 王浩力 添加
        public User LoginUser
        {
            get
            {
                string jiami = Request.Cookies[Globals.loginUserCookieKey].Value;
                var userName = DESEncrypt.Decrypt(jiami);
                var user = new UserBLL().GetUser(userName);
                //if (user != null)
                //{
                //    Session["userlogin"] = user;
                //}
                return user;
            }
        }

    }
}
